﻿CREATE TABLE [dbo].[RequestItemsSupporters] (
    [Id]            UNIQUEIDENTIFIER NOT NULL,
    [RequestItemId] UNIQUEIDENTIFIER NOT NULL,
    [CreatedBy]     UNIQUEIDENTIFIER NOT NULL,
    [CreatedByApp]  UNIQUEIDENTIFIER NULL,
    CONSTRAINT [PrimaryKey_44179414-5a8b-4b43-a2b0-4e60e68e18b7] PRIMARY KEY CLUSTERED ([Id] ASC),
    FOREIGN KEY ([CreatedByApp]) REFERENCES [dbo].[Apps] ([Id]),
    CONSTRAINT [FK_RequestItemsSupporters_0] FOREIGN KEY ([RequestItemId]) REFERENCES [dbo].[RequestItems] ([Id]) ON DELETE CASCADE,
    CONSTRAINT [FK_RequestItemsSupporters_1] FOREIGN KEY ([CreatedBy]) REFERENCES [dbo].[Users] ([Id]) ON DELETE CASCADE
);


GO
CREATE NONCLUSTERED INDEX [IX_RequestItem]
    ON [dbo].[RequestItemsSupporters]([RequestItemId] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_User]
    ON [dbo].[RequestItemsSupporters]([CreatedBy] ASC);

